package org.darcy.entity.privilege;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

@Schema(description = "SysMenu: 系统菜单权限")
@Data
@TableName(value = "sys_menu")
public class SysMenu implements Serializable {

	private static final long serialVersionUID = 1;

	@Schema(description = "")
	@TableId(type = IdType.AUTO)
	private Integer id;

	@Schema(description = "父模块id")
	@TableField(value = "`pid`")
	private Integer pid;

	@Schema(description = "名称")
	@TableField(value = "`name`")
	private String name;

	@Schema(description = "链接")
	@TableField(value = "`url`")
	private String url;

	@Schema(description = "标识")
	@TableField(value = "`sn`")
	private String sn;

	@Schema(description = "组件")
	@TableField(value = "`component`")
	private String component;

	@Schema(description = "是否启用 ： 1启用；0禁用")
	@TableField(value = "`status`")
	private Integer status;

	@Schema(description = "图片路径")
	@TableField(value = "`image`")
	private String image;

	@Schema(description = "模块的排序号")
	@TableField(value = "`order_no`")
	private Integer orderNo;

	@Schema(description = "创建时间")
	@TableField(value = "`create_time`")
	private Date createTime;

	@Schema(description = "更新时间")
	@TableField(value = "`update_time`")
	private Date updateTime;

	@Schema(description = "删除标识0:删除1：存在")
	@TableField(value = "`del_flag`")
	private Integer delFlag;

	// 扩展属性

	@Schema(description = "菜单id")
	@TableField(exist = false)
	private List<Integer> idList;

	@Schema(description = "是否选中")
	@TableField(exist = false)
	private Boolean checked;

	public static boolean inList(SysMenu data, List<Integer> idList) {
		for (Integer id : idList) {
			if (data.getId().equals(id)) {
				return true;
			}
		}
		return false;
	}

}
